<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" width="85%" destroy-on-close @closed="$emit('closed')" align-center>
        <el-container>
            <el-header>
                <div class="left-panel">
                    <!-- <el-button type="primary" @click="back">确定</el-button> -->
                    <!-- <el-button type="primary" icon="el-icon-plus" v-auth="'goods.add'" @click="add">新增</el-button> -->
                </div>
                <div class="right-panel">
                    <div class="right-panel-search">
                        <el-input v-model="search.production_code" placeholder="生产单编号" clearable @keyup.enter="upsearch"></el-input>
                        <el-date-picker v-model="search.create_time" :value-format="'YYYY-MM-DD'" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 230px" />
                        <el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
                        <el-button type="primary" icon="el-icon-refresh" @click="refresh"></el-button>
                    </div>
                </div>
            </el-header>
            <el-main class="nopadding">
                <scTable ref="table" row-key="id" :apiObj="apiObj" highlight-current-row @row-click="selectionChange" stripe remoteSort remoteFilter border height="650" :params="query">
                    <el-table-column type="index" label="序号" fixed align="center" width="60"></el-table-column>
                    <el-table-column label="任务单号" prop="deliver_code" align="center"></el-table-column>
                    <el-table-column label="销售单号" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="产品型号" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="速比" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="法兰" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="颜色" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="数量" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="客户" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="备注1" prop="plan.production_code" align="center"></el-table-column>
                    <el-table-column label="备注2" prop="plan.production_code" align="center"></el-table-column>
                </scTable>
            </el-main>
        </el-container>
		<template #footer>
			<el-button @click="visible = false">取 消</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
    props:{
        query: { type: Object, default: () => ({}) },
    },
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "add",
			titleMap: {
				add: '选择生产任务',
				edit: '编辑生产任务',
				show: '查看'
			},
			visible: false,
			isSaveing: false,
			apiObj: this.$API.production.send.list,
			selection: [],
			search: {
				production_code: null,
                level:null,
                create_time:null,
			},
		}
	},
	mounted() {
	},
	methods: {
		// 显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
        // 选择事件
        selectionChange(selection) {
            this.$emit('success', selection)
            this.visible = false;
		},
        // 选中返回
        back(){
            this.$emit('success', this.selection,this.type)
            this.visible = false;
        },
        //搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},
        refresh(){
            for (const key in this.search) {
                this.search[key] = null;
            }
            this.$refs.table.upData(this.search)
        },
	}
}
</script>

<style></style>
